import request from "@/utils/request";

/**
 * 获取购物车列表
 */
export function getCartList() {
	return request.get("/api/cart");
}

/**
 * 添加到购物车
 */
export function addToCart(data: { productId: number; quantity: number }) {
	return request.post("/api/cart", data);
}

/**
 * 更新购物车数量
 */
export function updateCartQuantity(id: number, quantity: number) {
	return request.put(`/api/cart/${id}`, { quantity });
}

/**
 * 从购物车移除
 */
export function removeFromCart(id: number) {
	return request.delete(`/api/cart/${id}`);
}

/**
 * 清空购物车
 */
export function clearCart() {
	return request.delete("/api/cart");
}
